<?php

use App\Http\Controllers\AdminController;
use App\Http\Controllers\ChapterController;
use App\Http\Controllers\ChapterDetailController;
use App\Http\Controllers\ChapterToDetailController;
use App\Http\Controllers\ProgrammingLanguageController;
use App\Http\Controllers\TrainingLevelContentController;
use App\Http\Controllers\TrainingLevelController;
use App\Http\Controllers\TrainingLevelHeadController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//编程语言
Route::group(['prefix' => 'test'], function () {

    //admin
    Route::post('login', [AdminController::class, 'login']);
    Route::post('logout/{admin}', [AdminController::class, 'logout']);
    Route::put('update/password/{admin}', [AdminController::class, 'updatePassword']);
    // Route::delete('programmingLanguages/{programmingLanguage}', [AdminController::class, 'destroy']);

    //编程语言名称
    Route::get('programmingLanguages', [ProgrammingLanguageController::class, 'index'])->middleware('auth:api');
    Route::post('programmingLanguages', [ProgrammingLanguageController::class, 'store']);
    Route::put('programmingLanguages/{programmingLanguage}', [ProgrammingLanguageController::class, 'update']);
    Route::delete('programmingLanguages/{programmingLanguage}', [ProgrammingLanguageController::class, 'destroy']);

    //章节
    Route::get('chapters', [ChapterController::class, 'index'])->middleware('auth:api');
    Route::post('chapters', [ChapterController::class, 'store']);
    Route::put('chapters/{chapter}', [ChapterController::class, 'update']);
    Route::delete('chapters/{chapter}', [ChapterController::class, 'destroy']);

    //章节详情
    Route::get('chapterdetails', [ChapterDetailController::class, 'index']);
    Route::post('chapterdetails', [ChapterDetailController::class, 'store']);
    Route::put('chapterdetails/{chapterdetail}', [ChapterDetailController::class, 'update']);
    Route::delete('chapterdetails/{chapterdetail}', [ChapterDetailController::class, 'destroy']);

    //章节和章节详情的中间表
    Route::get('chaptertodetails', [ChapterToDetailController::class, 'index']);
    Route::post('chaptertodetails', [ChapterToDetailController::class, 'store']);
    Route::put('chaptertodetails/{chaptertodetail}', [ChapterToDetailController::class, 'update']);
    Route::delete('chaptertodetails/{chaptertodetail}', [ChapterToDetailController::class, 'destroy']);

    //关卡名
    Route::get('traininglevels', [TrainingLevelController::class, 'index']);
    Route::post('traininglevels', [TrainingLevelController::class, 'store']);
    Route::put('traininglevels/{traininglevel}', [TrainingLevelController::class, 'update']);
    Route::delete('traininglevels/{traininglevel}', [TrainingLevelController::class, 'destroy']);

    //关卡标题
    Route::get('traininglevelheads', [TrainingLevelHeadController::class, 'index']);
    Route::post('traininglevelheads', [TrainingLevelHeadController::class, 'store']);
    Route::put('traininglevelheads/{traininglevelhead}', [TrainingLevelHeadController::class, 'update']);
    Route::delete('traininglevelheads/{traininglevelhead}', [TrainingLevelHeadController::class, 'destroy']);

    //关卡内容
    Route::get('traininglevelcontents', [TrainingLevelContentController::class, 'index']);
    Route::post('traininglevelcontents', [TrainingLevelContentController::class, 'store']);
    Route::put('traininglevelcontents/{traininglevelcontent}', [TrainingLevelContentController::class, 'update']);
    Route::delete('traininglevelcontents/{traininglevelcontent}', [TrainingLevelContentController::class, 'destroy']);

    Route::post('traininglevels/editCode', [TrainingLevelContentController::class, 'editCode']);
});
